import unittest

import os
import sys
import logging
import warnings
import threading
import time
import json
path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, path)

from contract_market.initialize import config  # NOQA
from contract_market.initialize.config import *  # NOQA
from contract_market.core.actor import *  # NOQA
from contract_market.core.core import *  # NOQA
from contract_market.server.engine import EventEngine  # NOQA
from contract_market.common.common import EventSystemEngine  # NOQA
from contract_market.common.constant import *  # NOQA
from contract_market.common.rpc.rpc import RPCClient, RPC  # NOQA
from contract_market.base.event import Event , EventData # NOQA
from contract_market.strategy.image.manager import ImageMarketEngine # NOQA
from contract_market.utils.restruct import run_subscribe # NOQA


def init_engine():

    event = EventCenter()
    engine = EventEngine(event)
    # engine.add_engine(QuantListener)
    print(event.obtain_events())
    return event, engine
    pass


class ImageTest(unittest.TestCase):
    
    @unittest.skip
    def test_init(self):

        cfg = InitConfig("image", "pair.yaml")
        print("[cfg]", cfg.resolve())

        imageMarketEngine = ImageMarketEngine(*init_engine(), configure=cfg)
        imageMarketEngine.start()
        imageMarketEngine.orderbook.start_price_sync()
    
    def test_redis_sub(self):
        run_subscribe()

if __name__ == "__main__":
    unittest.main()